var VideoDTOList = null;

function listVideo_andEvaluation_byUser() {

	/*
	 * 
	 */
	var xhr = false;
	xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		var message;
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {

				VideoDTOList = JSON.parse(xhr.responseText);

				/*
				 * 
				 * 清空原表数据
				 * 
				 */
				var new_tr_list = document.getElementsByClassName("new_tr");
				var long = new_tr_list.length;

				for (var num = 0; num < long; num++) {
					new_tr_list[0].parentNode.removeChild(new_tr_list[0]);
				}
				/*
				 * 
				 */
				var table_video = document.getElementById("table_video");

				var new_tr;
				var new_td;
				for (var num = 0; num < VideoDTOList.length; num++) {
					new_tr = document.createElement("tr");
					table_video.firstElementChild.appendChild(new_tr);
					new_tr.className = "new_tr";

					/*
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].teacher.teacher_name;
					/*
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].video.video_name;
					/*
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].video.video_recordDate;
					/*
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].video.video_lessonName;
					/*
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].video.video_grade;
					/*
					 * 
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					new_td.innerHTML = VideoDTOList[num].video.video_memo;
					/*
					 * 是否标注
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					if (VideoDTOList[num].styleEvaluation != null) {
						score = parseInt(VideoDTOList[num].styleEvaluation.styleEvaluation_dynamicTalkSpeed)
								+ parseInt(VideoDTOList[num].styleEvaluation.styleEvaluation_dynamicLoudness)
								+ parseInt(VideoDTOList[num].styleEvaluation.styleEvaluation_dynamicAction)
								+ parseInt(VideoDTOList[num].styleEvaluation.styleEvaluation_dynamicHumor)
								+ parseInt(VideoDTOList[num].styleEvaluation.styleEvaluation_dynamicFacialExpression)

						if (score <= 11) {
							dynamicStyleTypeText = "沉缓型";
						} else if (score <= 19) {
							dynamicStyleTypeText = "普通型";
						} else {
							dynamicStyleTypeText = "激奋型";
						}

						/*
						 * 
						 */
						new_td.innerHTML = "动态："
								+ dynamicStyleTypeText
								+ "，静态："
								+ VideoDTOList[num].styleEvaluation.styleEvaluation_staticStyleType;
					} else {
						if (login_json.user_type == "user") {
							new_td.innerHTML = '<i title="评注" id="'
									+ VideoDTOList[num].video.video_name
									+ '" class="fa fa-pencil" onclick="evaluationVideo(this)"></i>';
						} else {
							new_td.innerHTML = 'admin不可评注';
						}

					}
					/*
					 * 
					 */
					new_td = document.createElement("td");
					new_tr.appendChild(new_td);
					if (login_json.user_type == "user"
							&& VideoDTOList[num].styleEvaluation != null) {
						new_td.innerHTML = ''
								+ '<i title="删除标注" id="'
								+ VideoDTOList[num].styleEvaluation.styleEvaluation_id
								+ '" class="fa fa-trash" style="color:#ff5063;" onclick="deleteEvaluation(this)"></i>';
					} else if (login_json.user_type == "admin") {
						new_td.innerHTML = ''
								+ '<i title="修改教师（暂未实现）" id="'
								+ VideoDTOList[num].video.video_id
								+ '" class="fa fa-pencil" onclick="editVideoTeacher(this)"></i>&nbsp&nbsp<i title="删除视频" id="'
								+ VideoDTOList[num].video.video_id
								+ '" class="fa fa-trash" style="color:#ff5063;" onclick="deleteVideo(this)"></i>';
					}

				}

				// 让加载图标消失
				document.getElementById("i_pulse").style.display = "none";

			} else {
				// toastr.error(xhr.status);
			}
		}
	}
	var formData = new FormData();
	xhr.open("POST", "/jxfgyj/video/listVideoDTO");
	formData.append("filter_teacher", select_filter_teacher.value);
	formData.append("filter_evaluation", select_filter_evaluation.value);
	xhr.send(formData);

}
